package com.company.emallbackend.controller;

import com.company.emallbackend.common.Result;
import com.company.emallbackend.entity.Product;
import com.company.emallbackend.service.IStarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
* <p>
*  前端控制器
* </p>
*
* @author hanlijian
* @since 2023-01-12
*/
@RestController
@RequestMapping("/star")
@Api(tags = "点赞管理")
public class StarController {

    @Resource
    private IStarService starService;

    /**
     * 点赞商品
     * @param productId
     * @return
     */
    @GetMapping("addProductStar")
    @ApiOperation("点赞商品")
    public Result addProductStar(@RequestParam Integer productId){
        starService.addProductStar(productId);
        return Result.success();
    }

    /**
     * 查看我的点赞商品列表
     * @return
     */
    @GetMapping("getStarList")
    @ApiOperation("查看我的点赞商品列表")
    public Result getStarList(){
        List<Product> productList=starService.getStarList();
        return Result.success(productList);
    }
}
